<extend name="Layout:layout_list" />
<block name="head_after_block">    
    <link href="__THEME__Css/frm-edit-page.css" rel="stylesheet" type="text/css"/>
</block>
<block name="body_before_block">
    <script src="__THEME__Plugin/ajax_load_options.min.js" type="text/javascript"></script>
</block>
<block name="body_content_block">
    <form action="{:AddonU('XTool/data_clear')}" method="post" id="frmMain">
        <table>
            <if condition="$isSuperAdmin">
                <th>租户ID：</th><td><select name="siteID" title="请选择租户" required data-url="{:AddonU('Admin/get_admin_json')}" data-value="{$search.siteID}"></select>
                <else/>
                <tr style="display: none;"><input type="hidden" name="siteID" value="{$loginData.siteID}"/></td></tr>
            </if>
            <tr>
                <th>清理此日期以前的数据：</th><td>
                    <input type="text" class="easyui-datebox" name="date" placeholder="请选择清理时期界限" title="请选择清理时期界限 " value="{$search.date}"/>
                    <input type="button" id="btnSearch" value="查询" class="button"/>
                </td></tr>
            <tr>
                <th valign="top">清理内容：</th><td>
                    <input type="checkbox" id="chkAll" />全选<br />
                    <input type="checkbox" name="callhistory_all_today" value="1" />删除通话记录和录音文件(当天){$data.nCallHistory_today}<br />
                    <input type="checkbox" name="callhistory_rec_today" value="1"/>仅删除录音文件(当天){$data.nRecord_today}<br />
                    <input type="checkbox" name="callhistory_all" value="1" />删除通话记录和录音文件(当天之前){$data.nCallHistory}<br />
                    <input type="checkbox" name="callhistory_rec" value="1"/>仅删除录音文件(当天之前){$data.nRecord}<br />
            <if condition="$isSuperAdmin">
                <input type="checkbox" name="call_history_other" value="1"/>无归属清单和录音{$data.nCallHistory_other}<br/>
            </if>
            <input type="checkbox" name="seat_call_stat" value="1"/>策略外呼分析{$data.nseat_call_stat}<br/>
            <input type="checkbox" name="extension_call_stat" value="1"/>分机外呼分析{$data.nextension_call_stat}<br/>
            <input type="checkbox" name="seat_work_stat" value="1"/>座席工作统计{$data.nseat_work_stat}<br/>
            <input type="checkbox" name="seat_calltime_stat" value="1"/>分座席通话时长统计{$data.nseat_calltime_stat}<br/>
            <input type="checkbox" name="queue_calltime_stat" value="1"/>分队列通话时长统计{$data.nqueue_calltime_stat}<br/>
            <input type="checkbox" name="smshistory" value="1"/>短信清单{$data.nsmshistory}<br/>
            </td></tr>
            <tr><th>&nbsp;</th><td><input type="button" id="btnSave" value="立即清理" class="button"/></td></tr>
        </table>

        <input type="hidden" name="action" value=""/>
    </form>
</block>
<block name="body_after_block">
    <script>
        if ($('select[name="siteID"]')[0]) {
            ajax_load_options({selector: 'select[name="siteID"]', def_option: '选择租户'});
        }
        $('input[name="call_history"]').click(function () {
            if ($(this).prop('checked')) {
                $('#call_history_span').show();
            } else {
                $('#call_history_span').hide();
            }
        })
        $('#btnSearch').click(function () {
            $('input[name="action"]').val('search');
            $('#frmMain').submit();
        })
        $('#btnSave').click(function () {
            if (!confirm('您确定要清理数据吗?删除后数据将不可撤销!')) {
                return false;
            }
            $('input[name="action"]').val('clear');
            $('#frmMain').submit();
        })
        $('#chkAll').click(function () {
            $(this).nextAll().prop('checked', $(this).prop('checked'));
        })
    </script>
</block>